

ac.game:event '英雄-获得天赋'(function(_,hero,name,index)
    local player = hero.owner
    local cards = hero:get_data('展示天赋表') or {}
    local Lock = player:get_data('无法获得卡') or {}
    local temp = index and cards[index]
    if temp then
        Lock[temp.name] = nil
        temp:remove()
    end
    hero:add_skill(name,'隐藏')
end)

ac.game:event '单位-添加技能'(function(_,hero,skill)
    if skill.skill_type=='抽卡天赋' then
        local name = skill.name
        local player = hero.owner
        local Lock = player:get_data('无法获得卡') or {}
        local cards = hero:get_data('展示天赋表') or {}
        local haves = hero:get_data('拥有天赋表') or {}
        
        hero:set_data('展示天赋表',cards)
        hero:set_data('拥有天赋表',haves)
        if not skill.is_hide then
            local index = index or #cards + 1
            local temp = cards[index]
            for a=1,index do
                if cards[a]==nil then
                    index = a
                    break
                end
            end
            cards[index] = skill
        end

        if temp then
            Lock[temp.name] = nil
            temp:remove()
        end
        Lock[name] = true
        haves[name] = skill
        skill.is_card = true
        skill.show_class = skill.card_class2 and skill.card_class2[#skill.card_class2]
        skill.abis = {}
        for a=1,4 do
            local abi = skill['卡牌技能'..a]
            if abi then
                local ski = hero:add_skill(abi,'隐藏',nil,{art = skill.art,owner_skill = skill})
                table.insert(skill.abis,ski)
                skill:gc(ski)
            end
        end
        skill:gc(function()
            hero:notify('英雄-失去天赋',hero,skill)
        end)
        skill:notify('on_card',hero,player)
        hero:notify('英雄-抽卡完毕',hero,skill)
        hero:notify('天赋-检测合成',hero,skill)
        hero:notify('天赋-检测合成后',hero,skill)
        player:notify('玩家-刷新UI',player)
    
        if skill['品质']=='UR' or skill['品质']=='UR+' then
            ac.game:notify('游戏-播放UR介绍',skill['灰字介绍'])
        end
    end
end)

--有三张入口卡会关闭入口天赋
ac.game:event '英雄-抽卡完毕'(function(_,hero,temp)
    local player = hero.owner
    local pz = temp['品质']
    add_card_count(hero,pz,1)
    --计数添加
    for name in pairs(temp.card_class1) do
        add_card_count(hero,name,1)
    end
    --通用属性直接增加
    LoadItemSX(hero,temp.base_attr,1)
    hero:add('天赋数量',1)
end)


ac.game:event '英雄-失去天赋'(function(_,hero,temp)
    local player = hero.owner
    local cards = hero:get_data('展示天赋表') or {}
    local haves = hero:get_data('拥有天赋表') or {}
    local Lock = player:get_data('无法获得卡') or {}
    local pz = temp['品质']
    add_card_count(hero,pz,-1)
    hero:add('天赋数量',-1)
    --计数减少
    for name in pairs(temp.card_class1) do
        add_card_count(hero,name,-1)
    end
    if temp['保留属性']==nil then
        LoadItemSX(hero,temp.base_attr,-1)
    end
    Lock[temp.name] = nil
    haves[temp.name] = nil
    for a=1,12 do
        if cards[a]==temp then
            cards[a] = nil
            break
        end
    end
    player:notify('玩家-刷新UI',player)
end)



